#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,m;
    int arr[5][5];
    for (int i = 0; i < 5; ++i)
        for (int j = 0; j < 5; ++j)
            cin>>arr[i][j];
    cin>>n>>m;
    swap(arr[n-1],arr[m-1]);
    for (int i = 0; i < 5; ++i){
        for (int j = 0; j < 5; ++j)
            cout<<arr[i][j]<<' ';
        cout<<endl;
    }
    return 0;
}